/** @format */

import {service} from '../util/request';
import {to} from '../util';

const admin = {
  // 登录
  login(params: any) {
    return to(
      service({
        url: '/login',
        method: 'post',
        data: params,
      }),
    );
  },

  // 获取配置信息
  getConfig(params?: any) {
    return to(
      service({
        url: '/admin/getConfig',
        method: 'get',
        params,
      }),
    );
  },
  // 更新配置
  postConfig(params: any) {
    return to(
      service({
        url: '/admin/postConfig',
        method: 'post',
        data: params,
      }),
    );
  },
  getUserList() {
    return to(
      service({
        url: '/admin/getUserList',
        method: 'get',
      }),
    );
  },
  // 获取配置信息
  postPwd(params: any) {
    return to(
      service({
        url: '/admin/postPwd',
        method: 'post',
        data: params,
      }),
    );
  },
  // 删除拥护
  deleteUser(params: any) {
    return to(
      service({
        url: '/admin/deleteUser',
        method: 'delete',
        params,
      }),
    );
  },
  // 新增用户
  addUser(params: any) {
    return to(
      service({
        url: '/admin/addUser',
        method: 'post',
        data: params,
      }),
    );
  },
  // 获取文章markdown
  getArticleMarkdown(params: any) {
    return to(
      service({
        url: '/admin/getArticleMarkdown',
        method: 'get',
        params,
      }),
    );
  },

  // 上传文件
  uploadFile(params: any) {
    return to(
      service({
        url: '/admin/uploadFile',
        method: 'post',
        data: params,
      }),
    );
  },

  // 更新、上传文章
  addBlog(params: any) {
    return to(
      service({
        url: '/admin/addBlog',
        method: 'post',
        data: params,
      }),
    );
  },

  // 获取文章分页列表
  getArticlesList(params: any) {
    return to(
      service({
        url: '/admin/getArticlesList',
        method: 'get',
        params,
      }),
    );
  },
  // 删除
};

export {admin};

interface IAdminApis {
  getCategory: [string, 'get' | 'post' | 'put' | 'delete'];
}

const apis: IAdminApis = {
  getCategory: ['/getCategory', 'get'],
};

export default apis;
